<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="com.pojo.basic.Module"%>
<%@page import="com.pojo.basic.SALM"%>
<%@page import="com.pojo.basic.DEPT"%>
<%@page import="com.pojo.basic.ModuleUsers"%>
<%@page import="java.util.List"%>
<%@ include file="/default.jsp"  %>
<%
	List<SALM> salms  = (List<SALM>)request.getAttribute("listSalm");
	Module  module  =  (Module)request.getAttribute("module");
	List<DEPT> depts  = (List<DEPT>)request.getAttribute("deptList");
	List<ModuleUsers> moduleusers  = (List<ModuleUsers>)request.getAttribute("moduleUsersList");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>【模組設定】權限設定</title>
<link rel="stylesheet" href="/Sunlike/extjs/resources/css/ext-all.css" type="text/css"></link>
<link rel="stylesheet" href="/Sunlike/css/toolbar.css" type="text/css"></link>
<script type="text/javascript" src="/Sunlike/extjs/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="/Sunlike/extjs/ext-all-debug.js"></script>
<script type="text/javascript"  src="/Sunlike/js/Setting/toolbar.js"></script>
<script type="text/javascript" src="/Sunlike/jquery/jquery-1.5.1.js"></script>
<style type="text/css">
<!--
.style1 {color: white}
.style2 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
.style7 {font-family: Arial, Helvetica, sans-serif; font-size: 12; font-weight; }
a{text-decoration:none;color:black;};
-->
</style>
<script type="text/javascript">
function returnPervious(url)
{
	location.href=url;
}
function searchData()
{
	var dept = $("#searchDept").val();
	var keyword = $("#searchKeyword").val();
	location.href="moduleAction.searchModulePermissionData.action?moduleVo.dept="+dept+"&moduleVo.keyword="+keyword+"&moduleVo.id=<%= module.getId() %>";
}
function checkAll(status,id)
{
	var  objs = $(".checkall");
	for(var  i = 0 ; i < objs.length; i++){
		if(status) $(objs[i]).attr("checked",status);
		if(status==false) $(objs[i]).attr("checked",!$(objs[i]).attr("checked"));
	}
}
</script>
</head>

<body>
<div id='toolbarspan'></div>
<form action="moduleAction.saveModulePermissionData.action" method="post">
<input type="hidden" name="moduleVo.id" value="<%= module.getId() %>">
<br>

<table width="100%" cellspacing="0" cellpadding="0" align="center" border="0">
<tbody>
<tr> 
	<td width="60%"> 
	<div align="center"><font face="Arial, Helvetica, sans-serif" size="3"><b>
	 模組設定:權限設定:<font color="blue"><%= module.getName() %></font></b></font> 
	</div>
	</td>
</tr>
</tbody>
</table>

<table width="98%" border="0" align="center">
<tbody>
<tr>
	<td  width="100"><div align="left"><span><!--<input type="submit" name="restoreSetting" value="&nbsp;恢復預設權限&nbsp;" style="font-size:14px;">	  -->  </span></div></td>
    <td align="center">
   		 <span>部門<b> : </b>
         <select name="moduleVo.dept"  id="searchDept">
           <%
           	for(DEPT dept : depts){
           %>
           <option value="<%= dept.getDEP() %>"><%= dept.getNAME() %></option>
           <%
           	}
           %>
         </select>
		&nbsp;&nbsp;&nbsp;&nbsp;  
        關鍵字<b> : </b> 
        <input type="text" name="searchKeyword"  id="searchKeyword">
		&nbsp;&nbsp;
        <input type="button" name="search" value="&nbsp;搜尋&nbsp;"   style="font-size:16px;font-family:MSYHBD;"  onclick="searchData()">	
        <input type="button" name="clearAway" value="&nbsp;清除&nbsp;"   style="font-size:16px;font-family:MSYHBD;">	
		&nbsp;&nbsp;
         <input type="submit" name="privilegeSetting" value="&nbsp;存儲&nbsp;"   style="font-size:16px;font-family:MSYHBD;">  
	    </span>
	</td>
	<td align="right"><span> <input type="button" name="cancel" value="&nbsp;回上一頁&nbsp;"  style="font-size:14px;" onclick="returnPervious('/Sunlike/Setting/Module/permission.jsp')"></span></td>       	
 </tr>
</tbody>
</table>

<table width="98%" cellspacing="0" cellpadding="6" rules="groups" align="center">
    <thead> 
    <tr bgcolor="#ECE8D8" >
      <td width="4%"><div align="center"><font  style="font-size:16px;font-family:MSYHBD;"><span>No.</span></font></div></td> 
      <td> 
        <div align="center"><font  style="font-size:16px;font-family:MSYHBD;"><span>職稱</span></font></div>
      </td>
      <td> 
        <div align="left"><font  style="font-size:16px;font-family:MSYHBD;"><span>姓名/部門</span></font></div>
      </td>
      <td align="left"><font  style="font-size:16px;font-family:MSYHBD;"><span>權限&nbsp;&nbsp;<input type="checkbox"  onclick="checkAll(true,'encheck')" id='encheck'>全選&nbsp;<input type="checkbox"  onclick="checkAll(false,'discheck')" id='discheck'>反選</span></font></td>
      </tr>
    </thead> 
    
    <%
    	int i =1;
    	for(SALM  salm : salms){
    		String SAL_NO = salm.getSAL_NO();
    		String checked = "";
    		for(ModuleUsers moduleuser : moduleusers){
    			if(SAL_NO.equals(moduleuser.getPSWD_USR())){
    				checked = "checked";
    			}
    		}
    %>
    <tbody> 
    <tr>
      <td align="center" ><span><%= i++ %><b>.</b></span></td> 
      <td> 
        <div align="center"><span><font  style="font-size:16px;font-family:MSYHBD;"><%= salm.getPOS() %></font></span></div>
      </td>
      <td> 
        <div align="left"><span> 
          <input type="hidden" name="adrbok_id" value="GT8888">
          <font  style="font-size:16px;font-family:MSYHBD;" color="blue"><%= salm.getNAME() %>/<%= salm.getDEP()!=null?salm.getDEP().getNAME():"<font color='red'>未設置部門</font>" %></font> 
         </span></div>
      </td>
      <td align="left"><span>
           <input name="moduleVo.view" type="checkbox"  <%= checked %> value="<%= SAL_NO  %>" class="checkall"><font  style="font-size:16px;font-family:MSYHBD;">查看</font>
      </span></td>
      </tr>
    </tbody> 
   <%
    	}
   %>
</table>
</form>
</body>

</html>